From 76ec5868d255dcb9e9bdc900a4b737ca674fafa0 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 3 Mar 2008 13:19:44 +0000 Subject: [PATCH] ioemu: xenfb shared memory patch Share the internal xenfb backend buffer with sdl or vnc. All the needed functions are already in place because have been implemented for the previous cirrus vga shared memory patch. Signed-off-by: Stefano Stabellini --- tools/ioemu/hw/xenfb.c | 63 +++++++++++++++++++++++------------------- tools/ioemu/vl.h | 13 ++++++++- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/tools/ioemu/hw/xenfb.c b/tools/ioemu/hw/xenfb.c index f4c69a111c..3f22664b16 100644 --- a/tools/ioemu/hw/xenfb.c +++ b/tools/ioemu/hw/xenfb.c @@ -1112,36 +1112,38 @@ static void xenfb_guest_copy(struct xenfb *xenfb, int x, int y, int w, int h) { int line; - if (xenfb->depth == xenfb->ds->depth) { /* Perfect match can use fast path */ - for (line = y ; line < (y+h) ; line++) { - memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->ds->depth / 8), - xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth / 8), - w * xenfb->depth / 8); - } - } else { /* Mismatch requires slow pixel munging */ - /* 8 bit == r:3 g:3 b:2 */ - /* 16 bit == r:5 g:6 b:5 */ - /* 24 bit == r:8 g:8 b:8 */ - /* 32 bit == r:8 g:8 b:8 (padding:8) */ - if (xenfb->depth == 8) { - if (xenfb->ds->depth == 16) { - BLT(uint8_t, uint16_t, 3, 3, 2, 5, 6, 5); - } else if (xenfb->ds->depth == 32) { - BLT(uint8_t, uint32_t, 3, 3, 2, 8, 8, 8); - } - } else if (xenfb->depth == 16) { - if (xenfb->ds->depth == 8) { - BLT(uint16_t, uint8_t, 5, 6, 5, 3, 3, 2); - } else if (xenfb->ds->depth == 32) { - BLT(uint16_t, uint32_t, 5, 6, 5, 8, 8, 8); + if (!xenfb->ds->shared_buf) { + if (xenfb->depth == xenfb->ds->depth) { /* Perfect match can use fast path */ + for (line = y ; line < (y+h) ; line++) { + memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->ds->depth / 8), + xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth / 8), + w * xenfb->depth / 8); } - } else if (xenfb->depth == 24 || xenfb->depth == 32) { - if (xenfb->ds->depth == 8) { - BLT(uint32_t, uint8_t, 8, 8, 8, 3, 3, 2); - } else if (xenfb->ds->depth == 16) { - BLT(uint32_t, uint16_t, 8, 8, 8, 5, 6, 5); - } else if (xenfb->ds->depth == 32) { - BLT(uint32_t, uint32_t, 8, 8, 8, 8, 8, 8); + } else { /* Mismatch requires slow pixel munging */ + /* 8 bit == r:3 g:3 b:2 */ + /* 16 bit == r:5 g:6 b:5 */ + /* 24 bit == r:8 g:8 b:8 */ + /* 32 bit == r:8 g:8 b:8 (padding:8) */ + if (xenfb->depth == 8) { + if (xenfb->ds->depth == 16) { + BLT(uint8_t, uint16_t, 3, 3, 2, 5, 6, 5); + } else if (xenfb->ds->depth == 32) { + BLT(uint8_t, uint32_t, 3, 3, 2, 8, 8, 8); + } + } else if (xenfb->depth == 16) { + if (xenfb->ds->depth == 8) { + BLT(uint16_t, uint8_t, 5, 6, 5, 3, 3, 2); + } else if (xenfb->ds->depth == 32) { + BLT(uint16_t, uint32_t, 5, 6, 5, 8, 8, 8); + } + } else if (xenfb->depth == 24 || xenfb->depth == 32) { + if (xenfb->ds->depth == 8) { + BLT(uint32_t, uint8_t, 8, 8, 8, 3, 3, 2); + } else if (xenfb->ds->depth == 16) { + BLT(uint32_t, uint16_t, 8, 8, 8, 5, 6, 5); + } else if (xenfb->ds->depth == 32) { + BLT(uint32_t, uint32_t, 8, 8, 8, 8, 8, 8); + } } } } @@ -1180,7 +1182,10 @@ static int xenfb_register_console(struct xenfb *xenfb) { xenfb_invalidate, xenfb_screen_dump, xenfb); + dpy_colourdepth(xenfb->ds, xenfb->depth); dpy_resize(xenfb->ds, xenfb->width, xenfb->height); + if (xenfb->ds->shared_buf) + dpy_setdata(xenfb->ds, xenfb->pixels); if (qemu_set_fd_handler2(xc_evtchn_fd(xenfb->evt_xch), NULL, xenfb_dispatch_channel, NULL, xenfb) < 0) return -1; diff --git a/tools/ioemu/vl.h b/tools/ioemu/vl.h index 66e4ded2d3..fcaf70488d 100644 --- a/tools/ioemu/vl.h +++ b/tools/ioemu/vl.h @@ -942,7 +942,7 @@ struct DisplayState { void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); void (*dpy_resize)(struct DisplayState *s, int w, int h); void (*dpy_colourdepth)(struct DisplayState *s, int depth); - void (*dpy_setdata)(DisplayState *ds, void *pixels); + void (*dpy_setdata)(DisplayState *s, void *pixels); void (*dpy_refresh)(struct DisplayState *s); void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h); }; @@ -957,6 +957,17 @@ static inline void dpy_resize(DisplayState *s, int w, int h) s->dpy_resize(s, w, h); } +static inline void dpy_colourdepth(struct DisplayState *s, int depth) +{ + s->dpy_colourdepth(s, depth); +} + +static inline void dpy_setdata(DisplayState *s, void *pixels) +{ + s->dpy_setdata(s, pixels); +} + + int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base, unsigned long vga_ram_offset, int vga_ram_size); int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, -- 2.30.2